<template>
  <div>
    <el-table
      :data="goods"
      stripe
      border
      style="width: 100%"
      highlight-current-row>

      <el-table-column prop="gameId" label="id" width="180" align="center">
      </el-table-column>
      <el-table-column prop="gameName" label="名称" align="center">
      </el-table-column>
      <el-table-column prop="gameBriefIntro" label="简介" align="center" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="price" label="价格" align="center" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="saleCount" label="出售数量" align="center" show-overflow-tooltip>
      </el-table-column>
      <el-table-column prop="saleCount" label="是否下架" align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <el-switch v-model="scope.row.offShelf" active-color="#13ce66" inactive-color="#ff4949" :active-value="1"
                     :inactive-value="0" active-text="上架" inactive-text="下架"></el-switch>
        </template>
      </el-table-column>
      <el-table-column prop="releaseTime" label="发布时间" align="center" show-overflow-tooltip>
      </el-table-column>

    </el-table>

    <!-- 分页 -->
    <el-pagination
      background
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getGameGoods"
    />
  </div>
</template>

<script>
import goods from "@/api/game/goods";

export default {
  name: "goods",

  data() {
    return {
      goods: [], //游戏列表
      page: 1,  //当前页码
      limit: 20,  // 每页显示的商品数量
      total: 0,  // 商品总量
    }
  },

  activated() {
    this.getGameGoods()
  },

  methods: {
    getGameGoods(page = 1) {
      this.page = page
      const params = {
        page: this.page
      }
      goods.getGameGoodsInfoList(params)
      .then(result => {
        this.total = result.data.totalCount
        this.goods = result.data.list
      })
    }
  }

}
</script>

<style scoped>

</style>
